package Q349

import java.util.*
import java.util.HashSet


class Main {

}

fun main() {

}

class Solution {
    fun intersection(nums1: IntArray, nums2: IntArray): IntArray {
        val set: MutableSet<Int> = HashSet()
        val set1: MutableSet<Int> = HashSet()
        for (i in nums1) {
            set.add(i)
        }
        for (i in nums2) {
            set1.add(i)
        }
        set.retainAll(set1)
        var i = 0
        val result = IntArray(set.size)
        for (integer in set) {
            result[i++] = integer
        }
        return result
    }
}